package com.example.demo.test;

import java.util.LinkedList;
import java.util.Queue;

/**
 * 缓存库类工序
 */
public abstract class CacheAbstractWorkProcess extends AbstractWorkProcess {

    //队列
    private final Queue<Material> queue;

    public CacheAbstractWorkProcess(String name, String description) {
        super(name, description);
        queue = new LinkedList<>();
    }

    @Override
    public boolean getCurrentMaterial() {
        if (!getQueue().isEmpty()){
            Material peek = (Material) getQueue().poll();
            if(peek != null){
                this.setMaterial(peek);
                return true;
            }
        }
        return false;
    }

    @Override
    public void addMaterial(Material material) {
        getQueue().add(material);
    }

    public Queue<Material> getQueue(){
        return this.queue;
    }
}
